home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1998 March
/
Macworld (1998-03) (Disk 1).dmg
/
Shareware World
/
Info
/
For Developers
/
GhostScript 5.10
/
MacGS-510
/
files
/
pdf2dsc.ps
< prev
next >
Wrap
Text File
|
1997-07-19
|
4KB
|
121 lines
% Copyright (C) 1994, 1995, 1996, 1997 Aladdin Enterprises. All rights reserved.
%
% This file is part of Aladdin Ghostscript.
%
% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author
% or distributor accepts any responsibility for the consequences of using it,
% or for whether it serves any particular purpose or works at all, unless he
% or she says so in writing. Refer to the Aladdin Ghostscript Free Public
% License (the "License") for full details.
%
% Every copy of Aladdin Ghostscript must include a copy of the License,
% normally in a plain ASCII text file named PUBLIC. The License grants you
% the right to copy, modify and redistribute Aladdin Ghostscript, but only
% under certain conditions described in the License. Among other things, the
% License requires that the copyright notice and this notice be preserved on
% all copies.
% pdf2dsc.ps
% read pdf file and produce DSC "index" file.
%
% Input file is named PDFname
% Output file is named DSCname
%
% Run using:
% gs -dNODISPLAY -sPDFname=pdffilename -sDSCname=tempfilename pdf2dsc.ps
% Then display the PDF file with
% gs tempfilename
%
% Modified by Johannes Plass <plass@dipmza.physik.uni-mainz.de> 1996-11-05:
% Adds BoundingBox and Orientation if available.
% Modified by rjl/lpd 9/19/96
% Updates for compatibility with modified pdf_*.ps code for handling
% page ranges (i.e., partial files) better.
% Modified by Geoff Keating <Geoff.Keating@anu.edu.au> 7/3/96:
% include Title and CreationDate DSC comments (these are displayed by
% Ghostview);
% reduce the size of typical output files by a factor of about 3.
% Modified by L. Peter Deutsch 3/18/96:
% Removes unnecessary and error-prone code duplicated from pdf_main.ps
% Modified by L. Peter Deutsch for GS 3.33
% Originally by Russell Lang 1995-04-26
/DSCfile DSCname (w) file def
/DSCstring 255 string def
GS_PDF_ProcSet begin
pdfdict begin
PDFname (r) file
pdfopen begin
% setup for loop (init increment limit)
/FirstPage where { pop FirstPage } { 1 } ifelse
1
/LastPage where { pop LastPage } { pdfpagecount } ifelse
% write header and prolog
DSCfile (%!PS-Adobe-3.0\n) writestring
Trailer /Info knownoget
{
dup /Title knownoget
{
DSCfile (%%Title: ) writestring
DSCfile exch write==
}
if
/CreationDate knownoget
{
DSCfile (%%CreationDate: ) writestring
DSCfile exch write==
}
if
}
if
DSCfile (%%Pages: ) writestring
DSCfile 1 index 3 index sub 1 add DSCstring cvs writestring
DSCfile (\n%%EndComments\n) writestring
DSCfile (%%BeginProlog\n) writestring
DSCfile (/Page null def\n/Page# 0 def\n/PDFSave null def\n/DSCPageCount 0 def\n) writestring
DSCfile (/DoPDFPage {dup /Page# exch store pdfgetpage pdfshowpage } def\n) writestring
DSCfile (GS_PDF_ProcSet begin\npdfdict begin\n) writestring
DSCfile (%%EndProlog\n) writestring
DSCfile (%%BeginSetup\n) writestring
DSCfile PDFname write==only
DSCfile ( \(r\) file pdfopen begin\n) writestring
DSCfile (%%EndSetup\n) writestring
% process each page
{
DSCfile (%%Page: ) writestring
DSCfile 1 index DSCstring cvs writestring
DSCfile ( ) writestring
DSCfile 1 index DSCstring cvs writestring
DSCfile (\n) writestring
%BEGIN ##jp##
dup pdfgetpage /CropBox knownoget { % file maxpage pageno cropbox
DSCfile (%%PageBoundingBox: ) writestring
{DSCfile exch write=only DSCfile ( ) writestring} forall
DSCfile (\n) writestring
} if
dup pdfgetpage /Rotate knownoget { % file maxpage pageno angle
DSCfile (%%PageOrientation: ) writestring
90 div cvi 4 mod dup 0 lt {4 add} if
[(Portrait) (Landscape) (UpsideDown) (Seascape)] exch get
DSCfile exch writestring
DSCfile (\n) writestring
} if
%END ##jp##
DSCfile exch DSCstring cvs writestring
DSCfile ( DoPDFPage\n) writestring
} for
currentdict pdfclose
end
end
end
% write trailer
DSCfile (%%Trailer\n) writestring
DSCfile (currentdict pdfclose\nend\nend\nend\n) writestring
DSCfile (%%EOF\n) writestring
% close output file and exit
DSCfile closefile
quit
% end of pdf2dsc.ps